/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gitee.huangjianbo.supos.openapi.core.thread;

import io.gitee.huangjianbo.supos.openapi.core.config.SuposEndpoint;
import io.gitee.huangjianbo.supos.openapi.core.http.HttpLanguage;

/**
 * 调用上下文
 *
 * @author tomcat
 * @version 1.0
 */
/**
 * 客户端上下文默认实现类
 * <p>
 * 线程安全的上下文对象存储容器，用于维护以下配置信息：
 * 1. 认证票据（Ticket）
 * 2. API 访问凭证（AccessKey/SecretKey）
 * 3. 租户标识
 * 4. 服务端点配置
 * 5. 国际化语言设置
 *
 * @author tomcat
 * @version 1.0
 */
public final class ClientContextImpl implements ClientContext {

    /**
     * 用户认证票据，用于接口权限验证
     */
    private String ticket;
    /**
     * API 访问密钥标识
     */
    private String accessKey;
    /**
     * API 访问安全密钥，需配合 accessKey 使用
     */
    private String secretKey;
    /**
     * 多租户系统标识，用于数据隔离
     */
    private String tenantId;
    /**
     * SupOS 服务端点配置（包含协议/域名/端口）
     */
    private SuposEndpoint endpoint;
    /**
     * HTTP 请求语言设置，用于响应国际化
     */
    private HttpLanguage language;

    /**
     * 构造空上下文对象
     * <p>
     * 新建实例时各字段均为 null 值，需通过 setter 方法进行配置
     */
    public ClientContextImpl() {
        // 默认空构造器
    }

    @Override
    public String getTicket() {
        return ticket;
    }

    /**
     * {@inheritDoc}
     * 
     * @param ticket 认证票据（通常来自登录接口响应）
     */
    @Override
    public void setTicket(String ticket) {
        this.ticket = ticket;
    }

    @Override
    public String getAccessKey() {
        return accessKey;
    }

    @Override
    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    @Override
    public String getSecretKey() {
        return secretKey;
    }

    @Override
    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    @Override
    public String getTenantId() {
        return tenantId;
    }

    @Override
    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    @Override
    public SuposEndpoint getEndpoint() {
        return endpoint;
    }

    @Override
    public void setEndpoint(SuposEndpoint endpoint) {
        this.endpoint = endpoint;
    }

    @Override
    public HttpLanguage getLanguage() {
        return language;
    }

    @Override
    public void setLanguage(HttpLanguage language) {
        this.language = language;
    }

    @Override
    public void close() {
        // 预留资源释放方法，当前上下文不持有需要关闭的资源
        // 实现 Closeable 接口以支持 try-with-resources 语法
    }
}
